-- 跃浪之行
local yuelangzhixing = fk.CreateSkill {
    name = "mcdh_yuelangzhixing",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

yuelangzhixing:addEffect('active',{
    prompt = "#mcdh_YueLangZhiXing",
    can_use = function(self, player)
        return player:getMark("ncs_YueLangZhiXing_m-turn") ~= 1
    end,
    target_num = 0,
    card_num = 0,
    card_filter = Util.FalseFunc,
    target_filter = Util.FalseFunc,
    on_use = function(self, room, effect)
        local player = effect.from
        player:drawCards(player.maxHp - player:getHandcardNum(),self.name)
        player.room:setPlayerMark(player,"ncs_YueLangZhiXing_d",1)
        player.room:setPlayerMark(player,"ncs_YueLangZhiXing_m-turn",1)
    end,
})

yuelangzhixing:addEffect(fk.AskForCardUse,{
    can_trigger = function(self, event, target, player, data)
        local all_names = U.getAllCardNames("b",false)
        return player:hasSkill(self) and target == player and player:getMark("ncs_YueLangZhiXing_m-turn") ~= 1 and (data.pattern and Exppattern:Parse(data.pattern):matchExp("slash,jink|.|.|.|.|."))
    end,
    on_use = function(self, event, target, player, data)
        player:drawCards(player.maxHp - player:getHandcardNum(),self.name)
        player.room:setPlayerMark(player,"ncs_YueLangZhiXing_d",1)
        player.room:setPlayerMark(player,"ncs_YueLangZhiXing_m-turn",1)
    end,
})

yuelangzhixing:addEffect(fk.AskForCardResponse,{
    can_trigger = function(self, event, target, player, data)
        local all_names = U.getAllCardNames("b",false)
        return player:hasSkill(self) and target == player and player:getMark("ncs_YueLangZhiXing_m-turn") ~= 1 and (data.pattern and Exppattern:Parse(data.pattern):matchExp("slash,jink|.|.|.|.|."))
    end,
    on_use = function(self, event, target, player, data)
        player:drawCards(player.maxHp - player:getHandcardNum(),self.name)
        player.room:setPlayerMark(player,"ncs_YueLangZhiXing_d",1)
        player.room:setPlayerMark(player,"ncs_YueLangZhiXing_m-turn",1)
    end,
})

yuelangzhixing:addEffect(fk.CardUseFinished,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and player:getMark("ncs_YueLangZhiXing_d") == 1
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player,"ncs_YueLangZhiXing_d",0)
        local n = player:getHandcardNum()
        room:askToDiscard(player,{min_num=n-1,max_num=n-1,include_equip=false,skill_name=self.name,prompt="#mcdh_ylzx_discard",cancelable=false})
    end,
})

yuelangzhixing:addEffect(fk.CardRespondFinished,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and player:getMark("ncs_YueLangZhiXing_d") == 1
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player,"ncs_YueLangZhiXing_d",0)
        local n = player:getHandcardNum()
        room:askToDiscard(player,{min_num=n-1,max_num=n-1,include_equip=false,skill_name=self.name,prompt="#mcdh_ylzx_discard",cancelable=false})
    end,
})

Fk:loadTranslationTable {
    ["mcdh_yuelangzhixing"] = "踏潮",
    [":mcdh_yuelangzhixing"] = "『跃浪之行』<br>每回合限一次，出牌阶段或当你需要使用或打出【杀】或【闪】时，你可以将手牌补至体力上限，然后你下一次使用或打出牌后，将手牌弃至1张。",
    ["#mcdh_YueLangZhiXing"] = "跃浪之行：你可以将手牌补至体力上限",
    ["#mcdh_ylzx_discard"] = "跃浪之行：请选择要弃置的牌",
}

return yuelangzhixing